package com.example.goukakuproject;

import com.leftMenuHelper.Lession;
import com.leftMenuHelper.LessionAdapter;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class GKGrammartab extends Activity {

	private ListView listViewGram;
	int bai = 0;
	int trinhDo = 0;
	int soLuongNguPhap = 10;
	int nguPhapThu = 0;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_gkgrammartab);
		Intent callerIntent=getIntent();
		Bundle packageFromCaller = callerIntent.getBundleExtra("GrammarIntent");
		bai = packageFromCaller.getInt("bai");
		trinhDo = packageFromCaller.getInt("trinhdo");
		Toast.makeText(this, "Trình độ N" + trinhDo + ". Bài " + bai, Toast.LENGTH_SHORT).show();
		Lession lessonData[] = new Lession[soLuongNguPhap];       
        for (int i = 0; i< soLuongNguPhap; i++){
        	lessonData[i] =  new Lession(R.drawable.ic_launcher, "Ngữ pháp số " + (i+1));
        }        
         LessionAdapter adapter = new LessionAdapter(this,R.layout.listview_item_row, lessonData);               
         listViewGram = (ListView)findViewById(R.id.lvGramrList);                 
         listViewGram.setAdapter(adapter);    
         
         listViewGram.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
		 public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
				 Intent myIntent=new Intent(GKGrammartab.this,GKGrammardetail.class);		 
				 Bundle bundle=new Bundle();
				 bundle.putInt("trinhdo", trinhDo);
				 bundle.putInt("bai", bai);
				 bundle.putInt("nguphapthu", arg2 + 1);
				 myIntent.putExtra("GrammarTabIntent", bundle);
				 startActivity(myIntent);
			}
			
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.gkgrammartab, menu);
		return true;
	}

}
